﻿package mortal.game.net.command.arena
{
    import Framework.MQ.*;
    import Message.Command.*;
    import Message.Public.*;
    import com.gengine.debug.*;
    import mortal.game.cache.*;
    import mortal.game.control.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.game.view.arena.util.*;
    import mortal.mvc.core.*;

    public class ArenaCommand extends BroadCastCall
    {

        public function ArenaCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_2:SArenaOpen = null;
            var _loc_3:SArenaSignUpState = null;
            var _loc_4:SArenaPlayerResult = null;
            var _loc_5:SArenaMatch = null;
            var _loc_6:SArenaCrossBattles = null;
            var _loc_7:SMyArenaInfo = null;
            var _loc_8:SPublicInt = null;
            var _loc_9:SArenaPlayerRankUpdate = null;
            var _loc_10:SArenaPlayerRewardMsg = null;
            var _loc_11:SArenaPlayerReward = null;
            var _loc_12:SArenaTimeMsg = null;
            Log.debug("I have receive ArenaCommand");
            super.call(param1);
            switch(param1.messageHead.command)
            {
                case EPublicCommand._ECmdPublicArenaChannelMsg:
                {
                    break;
                }
                case EPublicCommand._ECmdPublicArenaOpen:
                {
                    _loc_2 = param1.messageBase as SArenaOpen;
                    if (_loc_2.copyType == ECopyType._ECopyTypeArena)
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaOpen, _loc_2);
                    }
                    else
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaOpen, _loc_2);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaClose:
                {
                    _loc_2 = param1.messageBase as SArenaOpen;
                    if (_loc_2.copyType == ECopyType._ECopyTypeArena)
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaClose, null);
                    }
                    else
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaClose, null);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaSignUp:
                {
                    _loc_3 = param1.messageBase as SArenaSignUpState;
                    if (ArenaUtil.isArenaCopyCode(_loc_3.code))
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaSignUp, _loc_3);
                    }
                    else
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaSignUp, _loc_3);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaResult:
                {
                    _loc_4 = param1.messageBase as SArenaPlayerResult;
                    if (ArenaUtil.isArenaCopyCode(_loc_4.code))
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaGetFightResult, _loc_4);
                    }
                    else
                    {
                        Cache.instance.heroArena.sArenaPlayerResult = _loc_4;
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaGetFightResult, _loc_4);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaMatch:
                {
                    _loc_5 = param1.messageBase as SArenaMatch;
                    if (ArenaUtil.isArenaCopyCode(_loc_5.code))
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaMatchSucc, _loc_5);
                    }
                    else
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaMatchSucc, _loc_5);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaPreOpen:
                {
                    break;
                }
                case EPublicCommand._ECmdPublicArenaToplistUpdate:
                {
                    break;
                }
                case EPublicCommand._ECmdPublicArenaPlayerUpdate:
                {
                    break;
                }
                case EPublicCommand._ECmdPublicArenaBattles:
                {
                    _loc_6 = param1.messageBase as SArenaCrossBattles;
                    if (ArenaUtil.isArenaCopyCode(_loc_6.code))
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaGetWatchingList, _loc_6);
                    }
                    else
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaGetWatchingList, _loc_6);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaMyInfo:
                {
                    _loc_7 = param1.messageBase as SMyArenaInfo;
                    if (ArenaUtil.isArenaCopyCode(_loc_7.copyCode))
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaGetRoleArenaInfo, _loc_7);
                    }
                    else
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaGetRoleArenaInfo, _loc_7);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaBegin:
                {
                    _loc_12 = param1.messageBase as SArenaTimeMsg;
                    if (ArenaUtil.isArenaCopyCode(_loc_12.code))
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaEnterArena, _loc_12.seconds);
                    }
                    else
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaEnterArena, _loc_12.seconds);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaReward:
                {
                    _loc_9 = param1.messageBase as SArenaPlayerRankUpdate;
                    break;
                }
                case EPublicCommand._ECmdPublicArenaEnterObserve:
                {
                    _loc_12 = param1.messageBase as SArenaTimeMsg;
                    if (ArenaUtil.isArenaCopyCode(_loc_12.code))
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaEnterAsObserver, _loc_12.seconds);
                    }
                    else
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaEnterAsObserver, _loc_12.seconds);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaLeaveArena:
                {
                    _loc_8 = param1.messageBase as SPublicInt;
                    if (ArenaUtil.isArenaCopyCode(_loc_8.publicInt))
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaLeaveArena, null);
                    }
                    else
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaLeaveArena, null);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaLevelInfo:
                {
                    _loc_8 = param1.messageBase as SPublicInt;
                    ArenaController.ArenaLevel = _loc_8.publicInt;
                    NetDispatcher.dispatchCmd(ServerCommand.ArenaUpdateArenaLevel, null);
                    break;
                }
                case EPublicCommand._ECmdPublicArenaRewardInfo:
                {
                    _loc_10 = param1.messageBase as SArenaPlayerRewardMsg;
                    if (_loc_10.copyType == ECopyType._ECopyTypeArena)
                    {
                        Cache.instance.arena.playerRewardDic = _loc_10.playerRewards;
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaUpdateRewardInfo, null);
                    }
                    else
                    {
                        Cache.instance.heroArena.playerRewardDic = _loc_10.playerRewards;
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaUpdateRewardInfo, null);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaRewardInfoUpdate:
                {
                    _loc_11 = param1.messageBase as SArenaPlayerReward;
                    if (_loc_11.copyType == ECopyType._ECopyTypeArena)
                    {
                        Cache.instance.arena.updatePlayerRewardInfo(_loc_11);
                        NetDispatcher.dispatchCmd(ServerCommand.ArenaUpdateRewardInfo, null);
                    }
                    else
                    {
                        Cache.instance.heroArena.updatePlayerRewardInfo(_loc_11);
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaUpdateRewardInfo, null);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaTopLevel:
                {
                    _loc_8 = param1.messageBase as SPublicInt;
                    if (_loc_8)
                    {
                        ArenaController.ArenaBTopLevel = _loc_8.publicInt;
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicZoneBArenaTopLevel:
                {
                    _loc_8 = param1.messageBase as SPublicInt;
                    if (_loc_8)
                    {
                        ArenaController.ArenaZoneBTopLevel = _loc_8.publicInt;
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
